<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 6.3.0">

  <link rel="apple-touch-icon" sizes="180x180" href="/blog/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/blog/images/Horse.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/blog/images/Horse.png">
  <link rel="mask-icon" href="/blog/images/logo.svg" color="#222">

<link rel="stylesheet" href="/blog/css/main.css">



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" integrity="sha256-HtsXJanqjKTc8vVQjO4YMhiqFoXkfBsjBWcX91T1jr8=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.css" integrity="sha256-Vzbj7sDDS/woiFS3uNKo8eIuni59rjyNGtXfstRzStA=" crossorigin="anonymous">

<script class="next-config" data-name="main" type="application/json">{"hostname":"yanlwsometing.gitee.io","root":"/blog/","images":"/blog/images","scheme":"Pisces","darkmode":false,"version":"8.16.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":{"enable":true,"show_result":true,"style":"flat"},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":false,"async":false,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"}}</script><script src="/blog/js/config.js"></script>

    <meta name="description" content="对比windows的优点 Linux提供更多的系统工具和命令行，能够快速解决问题 例如：比较两个文件是否完全相同 1234567# Linuxvimdiff f1 f2 # 文本文件diff f1 f2 # 非文本文件md5sum f1 f2 # 大文件# Windows# 安装md5工具  复杂问题，通过将小工具组合，解决效率高效 例如：列出一个c语言项目中所有被包含过的头文件 12# Linu">
<meta property="og:type" content="article">
<meta property="og:title" content="Linux入门">
<meta property="og:url" content="https://yanlwsometing.gitee.io/blog/2023/06/11/Linux%E5%85%A5%E9%97%A8/index.html">
<meta property="og:site_name" content="yanlwsometing">
<meta property="og:description" content="对比windows的优点 Linux提供更多的系统工具和命令行，能够快速解决问题 例如：比较两个文件是否完全相同 1234567# Linuxvimdiff f1 f2 # 文本文件diff f1 f2 # 非文本文件md5sum f1 f2 # 大文件# Windows# 安装md5工具  复杂问题，通过将小工具组合，解决效率高效 例如：列出一个c语言项目中所有被包含过的头文件 12# Linu">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://yanlwsometing.gitee.io/blog/images/Linux%E5%85%A5%E9%97%A8/image-20230611112722881.png">
<meta property="og:image" content="https://yanlwsometing.gitee.io/blog/images/Linux%E5%85%A5%E9%97%A8/image-20230611113000120.png">
<meta property="og:image" content="https://yanlwsometing.gitee.io/blog/images/Linux%E5%85%A5%E9%97%A8/02-alias-rm.jpg">
<meta property="article:published_time" content="2023-06-11T02:55:35.000Z">
<meta property="article:modified_time" content="2023-12-15T08:52:49.010Z">
<meta property="article:author" content="yanlw">
<meta property="article:tag" content="Linux">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://yanlwsometing.gitee.io/blog/images/Linux%E5%85%A5%E9%97%A8/image-20230611112722881.png">


<link rel="canonical" href="https://yanlwsometing.gitee.io/blog/2023/06/11/Linux%E5%85%A5%E9%97%A8/">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"https://yanlwsometing.gitee.io/blog/2023/06/11/Linux%E5%85%A5%E9%97%A8/","path":"2023/06/11/Linux入门/","title":"Linux入门"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>Linux入门 | yanlwsometing</title>
  








  <noscript>
    <link rel="stylesheet" href="/blog/css/noscript.css">
  </noscript>
</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="headband"></div>

  <main class="main">
    <div class="column">
      <header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/blog/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">yanlwsometing</p>
      <i class="logo-line"></i>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger" aria-label="搜索" role="button">
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/blog/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a></li><li class="menu-item menu-item-tags"><a href="/blog/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a></li><li class="menu-item menu-item-categories"><a href="/blog/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a></li><li class="menu-item menu-item-archives"><a href="/blog/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a></li><li class="menu-item menu-item-commonweal"><a href="/blog/404/" rel="section"><i class="fa fa-heartbeat fa-fw"></i>公益 404</a></li>
  </ul>
</nav>




</header>
        
  
  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AF%B9%E6%AF%94windows%E7%9A%84%E4%BC%98%E7%82%B9"><span class="nav-number">1.</span> <span class="nav-text">对比windows的优点</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E8%AE%A4%E8%AF%86Linux"><span class="nav-number">2.</span> <span class="nav-text">认识Linux</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-%E5%91%BD%E4%BB%A4%E6%A0%BC%E5%BC%8F"><span class="nav-number">2.1.</span> <span class="nav-text">1. 命令格式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-%E4%B8%8D%E5%8C%BA%E5%88%86%E7%B3%BB%E7%BB%9F%E7%9B%98"><span class="nav-number">2.2.</span> <span class="nav-text">2. 不区分系统盘</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-%E4%B8%B0%E5%AF%8C%E7%9A%84%E5%B7%A5%E5%85%B7"><span class="nav-number">2.3.</span> <span class="nav-text">3. 丰富的工具</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4-shell%E6%96%B9%E4%BE%BF%E7%9A%84%E5%8A%9F%E8%83%BD"><span class="nav-number">2.4.</span> <span class="nav-text">4. shell方便的功能</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#5-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F"><span class="nav-number">2.5.</span> <span class="nav-text">5. 正则表达式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#6-%E4%BB%BB%E5%8A%A1%E7%AE%A1%E7%90%86"><span class="nav-number">2.6.</span> <span class="nav-text">6. 任务管理</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#7-%E8%BE%93%E5%85%A5%E8%BE%93%E5%87%BA%E9%87%8D%E5%AE%9A%E5%90%91"><span class="nav-number">2.7.</span> <span class="nav-text">7. 输入输出重定向</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#8-%E7%AE%A1%E9%81%93%EF%BC%9A%E5%B7%A5%E5%85%B7%E7%BB%84%E5%90%88"><span class="nav-number">2.8.</span> <span class="nav-text">8. 管道：工具组合</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#9-%E8%84%9A%E6%9C%AC"><span class="nav-number">2.9.</span> <span class="nav-text">9. 脚本</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AD%A6%E4%BC%9ALinux"><span class="nav-number">3.</span> <span class="nav-text">学会Linux</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-RTFM"><span class="nav-number">3.1.</span> <span class="nav-text">1. RTFM</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-STFW"><span class="nav-number">3.2.</span> <span class="nav-text">2. STFW</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%B0%8F%E7%BB%93"><span class="nav-number">4.</span> <span class="nav-text">小结</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99"><span class="nav-number">5.</span> <span class="nav-text">参考资料</span></a></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="yanlw"
      src="/blog/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">yanlw</p>
  <div class="site-description" itemprop="description">穷则独善其身，达则兼济天下！</div>
</div>
<div class="site-state-wrap animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/blog/archives/">
          <span class="site-state-item-count">23</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/blog/categories/">
        <span class="site-state-item-count">9</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
          <a href="/blog/tags/">
        <span class="site-state-item-count">18</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author animated">
      <span class="links-of-author-item">
        <a href="https://gitee.com/yanlwsometing" title="Gitee → https:&#x2F;&#x2F;gitee.com&#x2F;yanlwsometing" rel="noopener me" target="_blank"><i class="fab fa-gitee fa-fw"></i>Gitee</a>
      </span>
      <span class="links-of-author-item">
        <a href="mailto:1977712019@qq.com" title="Mail → mailto:1977712019@qq.com" rel="noopener me" target="_blank"><i class="fa fa-envelope fa-fw"></i>Mail</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://weibo.com/" title="Weibo → https:&#x2F;&#x2F;weibo.com&#x2F;" rel="noopener me" target="_blank"><i class="fab fa-weibo fa-fw"></i>Weibo</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://twitter.com/" title="Twitter → https:&#x2F;&#x2F;twitter.com&#x2F;" rel="noopener me" target="_blank"><i class="fab fa-twitter fa-fw"></i>Twitter</a>
      </span>
  </div>

        </div>
      </div>
        <div class="back-to-top animated" role="button" aria-label="返回顶部">
          <i class="fa fa-arrow-up"></i>
          <span>0%</span>
        </div>
    </div>

    
  </aside>


    </div>

    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://yanlwsometing.gitee.io/blog/2023/06/11/Linux%E5%85%A5%E9%97%A8/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/blog/images/avatar.jpg">
      <meta itemprop="name" content="yanlw">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="yanlwsometing">
      <meta itemprop="description" content="穷则独善其身，达则兼济天下！">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="Linux入门 | yanlwsometing">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          Linux入门
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2023-06-11 10:55:35" itemprop="dateCreated datePublished" datetime="2023-06-11T10:55:35+08:00">2023-06-11</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar-check"></i>
      </span>
      <span class="post-meta-item-text">更新于</span>
      <time title="修改时间：2023-12-15 16:52:49" itemprop="dateModified" datetime="2023-12-15T16:52:49+08:00">2023-12-15</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/blog/categories/Linux/" itemprop="url" rel="index"><span itemprop="name">Linux</span></a>
        </span>
    </span>

  
    <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv">
      <span class="post-meta-item-icon">
        <i class="far fa-eye"></i>
      </span>
      <span class="post-meta-item-text">阅读次数：</span>
      <span id="busuanzi_value_page_pv"></span>
    </span>
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody"><h2 id="对比windows的优点"><a href="#对比windows的优点" class="headerlink" title="对比windows的优点"></a>对比windows的优点</h2><ol>
<li><p>Linux提供更多的系统工具和命令行，能够快速解决问题</p>
<p>例如：比较两个文件是否完全相同</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Linux</span></span><br><span class="line">vimdiff f1 f2 # 文本文件</span><br><span class="line">diff f1 f2 # 非文本文件</span><br><span class="line">md5sum f1 f2 # 大文件</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Windows</span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">安装md5工具</span></span><br></pre></td></tr></table></figure>
</li>
<li><p>复杂问题，通过将小工具组合，解决效率高效</p>
<p>例如：列出一个c语言项目中所有被包含过的头文件</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash">Linux</span></span><br><span class="line">find .-name &quot;*.[ch]&quot; | xargs grep &quot;#include&quot; | sort | uniq</span><br></pre></td></tr></table></figure>
</li>
<li><p>”面向程序员“，开源、高效、适应环境多</p>
</li>
</ol>
<span id="more"></span>

<h2 id="认识Linux"><a href="#认识Linux" class="headerlink" title="认识Linux"></a>认识Linux</h2><h3 id="1-命令格式"><a href="#1-命令格式" class="headerlink" title="1. 命令格式"></a>1. 命令格式</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">命令 参数1 参数2 ...</span><br></pre></td></tr></table></figure>

<h3 id="2-不区分系统盘"><a href="#2-不区分系统盘" class="headerlink" title="2. 不区分系统盘"></a>2. 不区分系统盘</h3><p><img src="/blog/images/Linux%E5%85%A5%E9%97%A8/image-20230611112722881.png" alt="image-20230611112722881"></p>
<h3 id="3-丰富的工具"><a href="#3-丰富的工具" class="headerlink" title="3. 丰富的工具"></a>3. 丰富的工具</h3><p>包搜索：<a target="_blank" rel="noopener" href="https://packages.ubuntu.com/">Ubuntu – Ubuntu Packages Search</a></p>
<p><img src="/blog/images/Linux%E5%85%A5%E9%97%A8/image-20230611113000120.png" alt="image-20230611113000120"></p>
<p>了解工具的运行（&#x3D;<strong>打开黑盒</strong>）：</p>
<ul>
<li><p>source：看源码，细致但较繁琐</p>
</li>
<li><p>trace：看踪迹，不全面但易理解</p>
<p><strong>踪迹工具<code>strace</code></strong> ：<code>system call trace</code>，记录程序运行过程中的系统调用信息</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="built_in">ls</span> 如何运行</span></span><br><span class="line">strace ls</span><br><span class="line">strance ls -l</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash"><span class="built_in">ls</span> 命令如何被寻找</span></span><br><span class="line">strace -f bash -c &quot;ls&quot;</span><br><span class="line"><span class="meta prompt_"></span></span><br><span class="line"><span class="meta prompt_"># </span><span class="language-bash">用户如何与man 交互</span></span><br><span class="line">strace -o strace.log -f man ls</span><br><span class="line">tail -f strace.log # 在另一个窗口执行</span><br></pre></td></tr></table></figure></li>
</ul>
<h3 id="4-shell方便的功能"><a href="#4-shell方便的功能" class="headerlink" title="4. shell方便的功能"></a>4. shell方便的功能</h3><ul>
<li><p>通过<code>Tab</code>键自动补全</p>
</li>
<li><p>通过上下方向键检索历史命令</p>
</li>
<li><p>可以通过<code>A-f</code>和<code>A-b</code>按键来按单词移动光标</p>
<ul>
<li>更多快捷键可以阅读<code>man readline</code></li>
</ul>
</li>
<li><p>通过<code>history</code>命令查看历史命令</p>
<ul>
<li>通过<code>!n</code>(<code>n</code>为历史命令的编号)再次执行命令</li>
<li>通过<code>!xxx</code>再次执行以<code>xxx</code>开头的最近一条命令</li>
</ul>
</li>
<li><p>通过<code>cd -</code>返回上一个工作目录</p>
</li>
<li><p>通配符<code>*</code>(任意长度的任意字符串), <code>?</code>(任意一个字符)和<code>[...]</code>(集合中的任意一个字符)</p>
</li>
<li><p>括号扩展<code>&#123;...&#125;</code> (例: <code>echo Hello-&#123;a,bb,ccc&#125;-&#123;1,2&#125;!</code>)</p>
</li>
<li><p><code>alias</code> 为常用命令设置别名，<code>alias ls=&quot;ls --color&quot;</code>。也可以写入<code>~/.bashrc</code>，打开终端时生效<img src="/blog/images/Linux%E5%85%A5%E9%97%A8/02-alias-rm.jpg" alt="img"></p>
</li>
</ul>
<h3 id="5-正则表达式"><a href="#5-正则表达式" class="headerlink" title="5. 正则表达式"></a>5. 正则表达式</h3><p>一般配合<code>grep</code>, <code>awk</code>, <code>sed</code>, <code>vim</code>等工具使用</p>
<h3 id="6-任务管理"><a href="#6-任务管理" class="headerlink" title="6. 任务管理"></a>6. 任务管理</h3><ul>
<li>最小化(在后台运行) :  <code>C-Z</code>+<code>bg</code><ul>
<li>或运行命令时通过末尾添加<code>&amp;</code>指定后台运行</li>
</ul>
</li>
<li>任务栏 : <code>jobs</code></li>
<li>最大化 : <code>fg</code></li>
<li>关闭  <code>kill</code><ul>
<li>一般通过<code>kill -9 进程号</code>强行关闭</li>
</ul>
</li>
<li>任务管理器 - <code>ps aux</code>, <code>top</code>, <code>htop</code></li>
</ul>
<h3 id="7-输入输出重定向"><a href="#7-输入输出重定向" class="headerlink" title="7. 输入输出重定向"></a>7. 输入输出重定向</h3><p>Linux上的程序在运行时默认打开了3个文件, 通过 “文件描述符”来编号:</p>
<ul>
<li>0号文件 - 标准输入(默认为当前终端)</li>
<li>1号文件 - 标准输出(默认为当前终端)</li>
<li>2号文件 - 标准错误(默认为当前终端)</li>
</ul>
<p>可通过<code>lsof -p 进程号</code>来查看打开的文件</p>
<h3 id="8-管道：工具组合"><a href="#8-管道：工具组合" class="headerlink" title="8. 管道：工具组合"></a>8. 管道：工具组合</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">+-------+  stdout   +------+  stdin   +-------+</span><br><span class="line">| prog1 | --------&gt; | pipe | -------&gt; | prog2 |</span><br><span class="line">+-------+           +------+          +-------+</span><br></pre></td></tr></table></figure>

<p>管道 &#x3D; 一个用于连接程序间输入输出的缓冲区。</p>
<p>例如上图，prog1和prog2为两个小工具，prog2需要prog1的输出，那么就需要当prog1将输出数据填入pipe中，prog2再进行读入。</p>
<p><code>xargs</code>: 一个特殊的命令, 可以将标准输入转变为命令的参数</p>
<p>青春版直播时钟</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">watch -t -n 1 &quot;echo -n &#x27;第五期一生一芯 | 周六 19:00~21:00 | &#x27;; \</span><br><span class="line">  date; echo &#x27;课程主页 https://ysyx.oscc.cc/docs/&#x27;&quot;</span><br></pre></td></tr></table></figure>



<p>无人值守重试操作</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">while ! git push origin HEAD; do echo &quot;retry&quot;; done</span><br><span class="line">while [[ `seq 1 10 | shuf | head -n 1` != &quot;1&quot; ]]; do echo &quot;retry&quot;; done</span><br></pre></td></tr></table></figure>

<p>自制CPU主频监视器</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">watch -n 1 &quot;cat /proc/cpuinfo | grep MHz | awk &#x27;&#123;print \$1 NR \$3 \$4 \$2&#125;&#x27;&quot;</span><br></pre></td></tr></table></figure>

<p>打包特定文件并上传到远端</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">find . -name &quot;*.pdf&quot; | xargs tar cj | ssh yzh@192.168.1.1 &#x27;cd ysyx; &gt; pdf.tar.bz2&#x27;</span><br></pre></td></tr></table></figure>

<h3 id="9-脚本"><a href="#9-脚本" class="headerlink" title="9. 脚本"></a>9. 脚本</h3><h2 id="学会Linux"><a href="#学会Linux" class="headerlink" title="学会Linux"></a>学会Linux</h2><p>以下工具覆盖了程序员绝大部分的需求</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">文件管理 - cd, pwd, mkdir, rmdir, ls, cp, rm, mv, tar，echo</span><br><span class="line">文件检索 - cat, more, less, head, tail, file, find</span><br><span class="line">输入输出控制 - 重定向, 管道, tee, xargs</span><br><span class="line">文本处理 - vim, grep, awk, sed, sort, wc, uniq, cut, tr</span><br><span class="line">正则表达式</span><br><span class="line">任务管理 - jobs, ps, top, kill, free, lsof</span><br></pre></td></tr></table></figure>

<p>先进的工具</p>
<ul>
<li>python vs. 计算器</li>
<li><a target="_blank" rel="noopener" href="https://github.com/search?q=awesome">awesome系列</a></li>
<li><a target="_blank" rel="noopener" href="https://github.com/nvbn/thefuck">thefuck</a> - 命令行智能纠错工具</li>
</ul>
<p>如果记不住</p>
<ul>
<li>尝试<code>-h</code>, <code>--help</code>等选项查看帮助信息</li>
<li><code>man</code></li>
</ul>
<p>更多工具的介绍</p>
<ul>
<li><a target="_blank" rel="noopener" href="https://missing.csail.mit.edu/">The Missing Semester of Your CS Education</a></li>
<li><a target="_blank" rel="noopener" href="https://github.com/jlevy/the-art-of-command-line">The Art of Command Line</a></li>
</ul>
<h3 id="1-RTFM"><a href="#1-RTFM" class="headerlink" title="1. RTFM"></a>1. RTFM</h3><p>学习Linux就要学会查阅Linux手册 <code>man</code></p>
<ul>
<li>查阅命令&#x2F;库函数&#x2F;系统文件等内容的手册</li>
<li><code>man man</code> - 学习如何RTFM</li>
<li><code>man ls</code> - 查看如何使用ls命令</li>
<li><code>man 3 printf</code> - 学习如何使用库函数printf</li>
<li><code>man -k xxx</code> - 检索含有关键字含有xxx的命令</li>
</ul>
<h3 id="2-STFW"><a href="#2-STFW" class="headerlink" title="2. STFW"></a>2. STFW</h3><p>使用搜索引擎帮助你找到解决方案</p>
<p>例如：终端实现分屏</p>
<ul>
<li>搜”Linux 分屏“ -&gt; 得知工具<code>tmux</code></li>
<li><code>apt-get install tmux</code></li>
<li>搜 “tmux 教程” -&gt; 阅读教程学习<code>tmux</code>的使用</li>
<li>有的地方还不太明白-&gt; <code>man tmux</code> -&gt; 解决</li>
</ul>
<h2 id="小结"><a href="#小结" class="headerlink" title="小结"></a>小结</h2><p>Linux比windows有众多的好处，它的优点值得我们去使用。也许在使用中会有很多不适，这就如同初碰智能手机一样，反正不会坏，多尝试就好了。</p>
<p>“一生一芯”的系列课程让我感触很多，其中很多的知识我都曾经学过，并且成绩不错（卷面成绩），可是事到如今，我依旧感觉基础不牢，也许就是因为没有坚持下来，没有做到”好记性不如烂笔头“。如今我已步入研究生的行列，得此良机，我想重新学习，重新温故，不求速成，但求融会贯通。</p>
<h2 id="参考资料"><a href="#参考资料" class="headerlink" title="参考资料"></a>参考资料</h2><p>[Linux入门教程 <a target="_blank" rel="noopener" href="https://www.bilibili.com/video/BV1Ud4y137kN/">第五期“一生一芯”计划 - P2]_哔哩哔哩_bilibili</a></p>

    </div>

    
    
    

    <footer class="post-footer">
          <div class="post-tags">
              <a href="/blog/tags/Linux/" rel="tag"># Linux</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/blog/2023/06/10/%E8%AE%A4%E7%9C%9F%E7%9A%84%E6%8F%90%E9%97%AE/" rel="prev" title="认真的提问">
                  <i class="fa fa-chevron-left"></i> 认真的提问
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/blog/2023/06/12/Linux%EF%BC%88%E4%B8%80%EF%BC%89/" rel="next" title="Linux（一）">
                  Linux（一） <i class="fa fa-chevron-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">


<div class="copyright">
  &copy; 
  <span itemprop="copyrightYear">2023</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">yanlw</span>
</div>
<div class="busuanzi-count">
    <span class="post-meta-item" id="busuanzi_container_site_uv">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-item" id="busuanzi_container_site_pv">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/pisces/" rel="noopener" target="_blank">NexT.Pisces</a> 强力驱动
  </div>

    </div>
  </footer>

  
  <div class="reading-progress-bar"></div>

  <a href="https://gitee.com/yanlwsometing" class="github-corner" title="在 GitHub 上关注我" aria-label="在 GitHub 上关注我" rel="noopener" target="_blank"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.4/jquery.min.js" integrity="sha256-oP6HI9z1XaZNBrJURtCoUT5SUnxFr8s3BzRl+cbzUq8=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.js" integrity="sha256-yt2kYMy0w8AbtF89WXb2P1rfjcP/HTHLT7097U8Y5b8=" crossorigin="anonymous"></script>
<script src="/blog/js/comments.js"></script><script src="/blog/js/utils.js"></script><script src="/blog/js/next-boot.js"></script>

  


  <script src="/blog/js/third-party/fancybox.js"></script>



  
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>





</body>
</html>
